package com.cn.cxq.mvc;

import java.sql.Connection;

import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.WebArgumentResolver;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.RequestAttributes;

import com.cn.cxq.bean.User;


public class UtilsArgumentResolver implements WebArgumentResolver {

	public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) throws Exception {
		if (methodParameter.getParameterType().equals(User.class)) {
			return webRequest.getAttribute("user", RequestAttributes.SCOPE_REQUEST);
		}else if(methodParameter.getParameterType().equals(Connection.class)){
			return webRequest.getAttribute("con", RequestAttributes.SCOPE_REQUEST);
		}
		return UNRESOLVED;
	}
}
